// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System;
using System.Data;

namespace SnapObjects.Data
{
    internal class SqlBuilderParameter : AdoDbParameter, ISqlBuilderParameter
    {
        public SqlBuilderParameter(
            string name,
            Type type,
            ParameterDirection direction = ParameterDirection.Input) : base("", null, type, direction)
        {
            this.Name = name;
        }

        public SqlBuilderParameter(
            string placeholdName,
            string name,
            Type type,
            ParameterDirection direction = ParameterDirection.Input) : this(name, type, direction)
        {
            this.PlaceholdName = placeholdName.Replace('-', '_');
        }

        /*public static SqlBuilderParameter Create(ISqlParameter sqlParameter)
        {
            return new SqlBuilderParameter(sqlParameter.Name, sqlParameter.DataType, sqlParameter.Direction);
        }*/

        /// <summary>
        ///     Gets the name of the parameter.
        /// </summary>
        public string Name { get; set; }

        public string PlaceholdName { get; set; }

        /// <summary>
        ///     Gets the data type of the parameter.
        /// </summary>
        public Type DataType => this.ClrType;
    }
}
